package parts5.lesson67;

import java.text.SimpleDateFormat;

public class Demo6 {
    //验证一个字符是日期或日期时间，如果是则变成Date类型
    public static void main(String[] args) throws Exception {
        String str="88547745";
        String str2="01088547745";
        String str3="(010)-88547745";
        String regex="((\\(\\d{3,4}\\)-)|(\\d{3,4}))?\\d{7,8}";
        String regex2="(\\d{3,4})?\\d{7,8}";

        System.out.println(str.matches(regex));
        System.out.println(str2.matches(regex2));
        System.out.println(str3.matches(regex));
    }
}
